Skip to content

Emit otel from Cosmos Db Preview Emulator#15671

Open
afscrome wants to merge 1 commit intomicrosoft:mainfrom
afscrome:cosmosdb-otel
Open

Emit otel from Cosmos Db Preview Emulator#15671
afscrome wants to merge 1 commit intomicrosoft:mainfrom
afscrome:cosmosdb-otel

Conversation

@afscrome
Copy link
Copy Markdown
Contributor

Description

Update the cosmos preview emulator to emit open telemetry by default.

Note, this change currently requires a preview build of the preview emulator
x => x.WithImageTag("vnext-EN20260331pre"). To test this, you can update the playground app to specify that version. See Azure/azure-cosmos-db-emulator-docker#277 for more details.

var cosmos = builder.AddAzureCosmosDB("cosmos")
  .RunAsPreviewEmulator(x => x.WithImageTag("vnext-EN20260331pre"));

Fixes #15592, #13136

cc @lionelc @udsmicrosoft

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

Copilot AI review requested due to automatic review settings March 28, 2026 13:10
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15671

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15671"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Azure Cosmos DB Linux-based preview emulator integration to emit OpenTelemetry telemetry by default when run under Aspire, aligning emulator behavior with other OTLP-enabled resources.

Changes:

  • Enable OTLP exporter wiring for the Cosmos DB preview emulator via WithOtlpExporter() and ENABLE_OTLP_EXPORTER=true.
  • Update the emulator surrogate resource type declaration to include IResourceWithEnvironment.
  • Switch the Cosmos end-to-end playground app host to use RunAsPreviewEmulator().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs Enables OTLP exporter + emulator-specific env var for the preview emulator path.
src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBEmulatorResource.cs Adjusts implemented interfaces for the emulator wrapper resource.
playground/CosmosEndToEnd/CosmosEndToEnd.AppHost/Program.cs Moves the playground to the preview emulator to exercise the updated behavior.

Comment on lines +150 to +151
emulatorSurrogateBuilder.WithOtlpExporter()
.WithEnvironment("ENABLE_OTLP_EXPORTER", "true");
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new default OTLP configuration for the preview emulator (WithOtlpExporter + ENABLE_OTLP_EXPORTER) isn’t covered by the existing CosmosDB extension tests. Please add a test that verifies RunAsPreviewEmulator registers OTLP exporter configuration (e.g., presence of OtlpExporterAnnotation / environment callback) and that the ENABLE_OTLP_EXPORTER environment variable is set for the preview emulator container.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to 10
var cosmos = builder.AddAzureCosmosDB("cosmos")
.RunAsPreviewEmulator();

Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description notes that validating OTLP emission currently requires running the preview emulator with a specific image tag (via the configureContainer callback). This playground update switches to RunAsPreviewEmulator but doesn’t set the image tag, so it won’t exercise the intended scenario until the default tag includes the required build. Consider updating this call to pass a configureContainer callback that sets the image tag (or add a comment explaining why the playground intentionally uses the default tag).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure Cosmos Preview emulator to emit otel

2 participants